Skip to content

Conversation

@sergeevik
Copy link

In js array may be object with key as index
some another fix:

  • remove generic in string method. replace with toString
  • applyInner check not null before use in matcher
  • check ? when arg type is operator by toString.equals (? is char in value)
  • 2 test for each partial expression

In js array may be object with key as index
some another fix:
- remove generic in string method. replace with toString
- applyInner check not null before use in matcher
- check ? when arg type is operator by toString.equals (? is char in value)
- 2 test for each partial expression
lhs = new HashMap();
for (int i = 0; i < tempLhs.size(); i++) {
((HashMap) lhs).put(i, tempLhs.get(i));
}
Copy link
Author

@sergeevik sergeevik Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better:

var lhsNewMap =  new HashMap();
var lhsOldList = (List)lhs;
for (int i = 0; i < lhsOldList.size(); i++) {
  lhsNewMap.put(i, tempLhs.get(i));
}
lhs = lhsNewMap;

@uw4 uw4 self-assigned this Dec 18, 2025
@uw4 uw4 requested a review from aeberhart December 18, 2025 15:57
Copy link
Contributor

@uw4 uw4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks + good catch!
We're reviewing this behavior of $each with list as input -
we want to clarify this with the original Jsonata maintainers, might be as well be a glitch in the original impl

@sergeevik
Copy link
Author

sergeevik commented Jan 23, 2026

find some another bug caused by this fix.
fix realisation wrapped all partial expression. but need only to each (caught bug with $map function)

@uw4 @aeberhart any updates about for this bug?

memory pill for me:

json:

{
  "buildings": {
    "home": {
      "address": "home address",
      "period": "11 month on 12",
      "presentation": {
        "first": {
          "widget": {
            "data": "home widget"
          }
        }
      }
    },
    "work": {
      "address": "work address",
      "presentation": {
        "first": {
          "widget": {
            "data": "work widget"
          }
        }
      }
    },
    "vacancy": {
      "address": "vacancy address",
      "period": "1 month on 12",
      "presentation": {
        "first": {
          "widget": {
            "data": "vacancy widget"
          }
        }
      }
    },
    "old": {
      "address": "old address",
      "period": "2 month on 12",
      "presentation": {
        "first": {
          "widget": {
            "data": "old widget"
          }
        }
      }
    },
    "operation": {
      "address": "operation address",
      "period": "3 month on 12",
      "presentation": {
        "first": {
          "widget": {
            "data": "operation widget"
          }
        }
      }
    }
  }
}

and expression

$sift($.buildings, function($v, $k) { $k ~> /o/ and $v.presentation.*.widget})
                    ~> $each(?, function($v, $key) {{ $key: $sift($v.presentation, function($v, $k){ $v.widget }) }})
                    ~> $map(?, function($v){($v.*)})

not fork after this fix and not coverage by tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants